home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / gbuf.h < prev    next >
C/C++ Source or Header  |  1994-10-10  |  4KB  |  101 lines

  1. /* Graphics buffer is a file, which consists of the number of "bounds".
  2.    Each "bound" is a part of virtual graphics page, with the same width,
  3.    and relatively low height. We can load "bound" with given number to
  4.    memory, change it, show it on screen, swap to disk buffer. Format of
  5.    bound is the same as in image (int, int, bitmap).
  6.    Do not use buffer < than screen.
  7.  
  8.    If you do not use interface library of KNOW-HOW, some files are
  9.        not necessary, as event.lib, and other. It is possible to exclude
  10.        them from project. In this case you should edit colors.cpp file,
  11.        and remove some functions: pColorSet, init_Know_How and so on.
  12.        You need only pScreenSet structure, declared in colors.h.
  13. */
  14.  
  15. #ifndef __GRAPH_BUF_
  16. #define __GRAPH_BUF_
  17.  
  18. #include "image.h"
  19. #include "b&w.h"
  20. #include "patterns.h"
  21. #include "ic_part.h"
  22. #include <stdio.h>
  23.  
  24. #define BOUND_SIZE 12500/2   // size of bound, bytes
  25.  
  26. enum { LEFT, UP, RIGHT, DN };
  27. extern int image_size(int width, int heigth, int bitpx, int nplanes);
  28. extern int get_color_mult(int src_max_color, int dest_max_color);
  29.  
  30. class GrafBuffer
  31.     {
  32.     public:
  33.     int loaded;            // is the buffer ready?
  34.     loc buf_dim;           // buffer dimentions, pixels
  35.     loc bound_size;        // dimentions of bounds, bound_size.X == buf_dim.X
  36.     rect screen_area;      // screen work area (l, t, r, b)
  37.     rect screen_position;  // position of screen in buffer
  38.     FILE* buffer;          // swap file
  39.     char* file_name;       // swap file
  40.     imageP image;          // image for bound
  41.     int nplanes;           // number of planes
  42.     int bitpx;             // bit per pixel in plane
  43.     int change_palette;    // use or not the palette when loading or saving PCX
  44.         int transparent;       // What color show as transparent
  45.         int mode;              // COPY_PUT ...
  46.     public:
  47.     GrafBuffer(loc dim, char* swapName,
  48.            rect screen_area = rect(0, 0, getmaxx(), getmaxy()),
  49.            int bpx = 1, int np = 4);
  50.     ~GrafBuffer() { fclose(buffer); delete image; unlink(file_name);
  51.             delete file_name; }
  52.  
  53.     long imagesize(); // if image > 64K, BGI function returns error
  54.     int imagesize(int x, int y);
  55.  
  56.         void set_screen_area(rect a) { screen_area = a; }
  57.         void set_screen_position(rect a) { screen_position = a; }
  58.     int b_open();     // open swap file (created by constructor)
  59.     void b_close();    // close swap file
  60.  
  61.     void clear();      // fills buffer file with '0'
  62.     loc get_dim() { return buf_dim; }
  63.         rect get_screen_pos() { return screen_position; }
  64. //    loc get_bound_size() { return bound_size; }
  65.  
  66.         void set_mode(int m) { mode = m; }
  67.         void set_trans(int t) { transparent = t; }
  68.  
  69.     imageP get_bound(int number);
  70.     void put_bound(int number);
  71.     void get_BW(int number);  // get bound and keep it as BW
  72.  
  73.     void bound_screen(int number,      // put image from bound to screen src - in image, dest - on screen
  74.          loc comp_s = loc(1, 1),   // divx, divy, multx, multy
  75.          loc comp_d = loc(1, 1));  // rects are the outlines
  76.  
  77.     void screen_bound(int number);  // load bound from disk to memory, update from screen, put back
  78.  
  79.     void screen_buffer();       // swap screen to buffer
  80.     void buffer_screen(loc comp_s = loc(1, 1),   // from buffer to screen
  81.                loc comp_d = loc(1, 1));
  82.     void buffer_screen(rect temp,
  83.                loc comp_s = loc(1, 1),   // from buffer to screen
  84.                loc comp_d = loc(1, 1));
  85.  
  86.  
  87.     void buffer_disk(rect src, char* name);   // cut and paste
  88.  
  89.     void scroll(int shift, int direction, int show = 1);    // scrolling
  90.  
  91.     void pcx_buffer_file(rect src, char* name);
  92.     friend int pcx_file_buffer(GrafBuffer* buf, loc pos, char* name,
  93.                                int col = 16);
  94.  
  95. // Virtual BGI support
  96.     friend void dither_BW(int** threshold, rect coord, loc dim,
  97.               GrafBuffer* buf);
  98.     friend void bar(GrafBuffer* buf, rect coord);    // bar in buffer
  99.     };
  100.  
  101. #endif __GRAPH_BUF_